﻿@model  List<Microsoft.AspNetCore.Authentication.AuthenticationScheme>
@using System.Collections.Generic
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Authentication
@using cloudscribe.Core.Models
@using cloudscribe.Core.Web
@using cloudscribe.Core.Web.Components
@using Microsoft.Extensions.Options
@using Microsoft.Extensions.Localization
@inject SiteContext Tenant
@inject IStringLocalizer<CloudscribeCore> sr
@inject SiteContext site
@{
    var socFormat = ViewData["SocialFormat"].ToString();
    
}
    @functions {
        public string GetIconForLogin(string displayName)
        {
            switch (displayName)
            {
                case "Facebook":
                    return "<i class='fa fa-facebook-square' aria-hidden='true'></i>";
                case "Google":
                    return "<i class='fa fa-google' aria-hidden='true'></i>";
                case "Twitter":
                    return "<i class='fa fa-twitter' aria-hidden='true'></i>";
                case "Microsoft":
                    return "<i class='fa fa-windows' aria-hidden='true'></i>";


            }

            return "<i class='fa fa-arrow-circle-right' aria-hidden='true'></i>";
        }
        public string GetDisplayName(string displayName)
        {
            if (displayName == "OpenIdConnect")
            {
                return Tenant.OidConnectDisplayName;
                
            }

            return displayName;
        }
    }
   
        
<section id="socialLoginForm">
    <h4>@ViewData["SocialHeading"]</h4>
    <form asp-controller="Account" asp-action="ExternalLogin" asp-route-returnurl='@ViewData["ReturnUrl"]' method="post" class="form-horizontal" role="form">
        <div id="socialLoginList">
            <p>
                @foreach (Microsoft.AspNetCore.Authentication.AuthenticationScheme p in Model)
                {
                    <button type="submit" class="btn btn-default" id="@p.Name" name="provider" value="@p.Name"
                            title="@string.Format(socFormat,p.DisplayName)">
                        @Html.Raw(GetIconForLogin(p.DisplayName))
                        @GetDisplayName(p.DisplayName)
                    </button>
                }
            </p>
        </div>
    </form>
</section>
                